import 'package:flutter/material.dart';
import 'package:flutter_layout/base/app_colors.dart';
import 'package:flutter_layout/pages/custom/home_page.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:lottie/lottie.dart';
// import 'package:flutter_statusbar_manager/flutter_statusbar_manager.dart';

class SplashPage extends StatefulWidget {
  const SplashPage({Key? key}) : super(key: key);

  @override
  _SplashPageState createState() => _SplashPageState();
}

class _SplashPageState extends State<SplashPage> with TickerProviderStateMixin {
  AnimationController? _controller;

  @override
  void initState() {
    super.initState();
    _controller = AnimationController(
      duration: const Duration(seconds: (5)),
      vsync: this,
    );
  }

  @override
  Widget build(BuildContext context) {
    //设置尺寸（填写设计中设备的屏幕尺寸）如果设计基于360dp * 690dp的屏幕
    ScreenUtil.init(
        BoxConstraints(maxWidth: MediaQuery.of(context).size.width, maxHeight: MediaQuery.of(context).size.height),
        designSize: const Size(705, 1334),
        context: context,
        minTextAdapt: true,
        orientation: Orientation.portrait);
    return Container(
      color: AppColors.white,
      width: ScreenUtil().scaleWidth,
      height: ScreenUtil().scaleHeight,
      child: Lottie.asset(
        'assets/splash_lottie.json',
        controller: _controller,
        height: ScreenUtil().scaleHeight * 1,
        animate: true,
        onLoaded: (composition) {
          Get.back();
          _controller!
            ..duration = composition.duration
            ..forward().whenComplete(() =>
                //  Get.replace(const HomePage()));
                Navigator.pushReplacement(
                  context,
                  MaterialPageRoute(builder: (context) => const HomePage()),
                ));
        },
      ),
    );
  }
  // @override
  // Widget build(BuildContext context) {
  //   setStatus();
  //   return Scaffold(
  //     appBar: AppBar(
  //       backgroundColor: Colors.green,
  //       foregroundColor: Colors.white,
  //       toolbarHeight: 0,
  //       shadowColor: Colors.transparent,
  //       centerTitle: true,
  //       title: const Text(
  //         "状态栏",
  //         // style: TextStyle(fontSize: 10.h),
  //       ),
  //     ),
  //     body: Container(
  //       child: Text("111111"),
  //     ),
  //   );
  // }

//   void setStatus() {
//     FlutterStatusbarcolor.setStatusBarColor(Colors.pink);
// // if (useWhiteForeground(Colors.green[400])) {
//     FlutterStatusbarcolor.setStatusBarWhiteForeground(true);
//     // FlutterStatusbarcolor.setStatusBarWhiteForeground(false);

// // // change the navigation bar color to material color [orange-200]
//     FlutterStatusbarcolor.setNavigationBarColor(Colors.pink);
//     FlutterStatusbarcolor.setNavigationBarWhiteForeground(true);
//     // FlutterStatusbarcolor.setNavigationBarWhiteForeground(false);
// // // get statusbar color and navigationbar color
//     Future<Color?> statusbarColor = FlutterStatusbarcolor.getStatusBarColor();
//     Future<Color?> navigationbarColor = FlutterStatusbarcolor.getNavigationBarColor();

//   }
}
